#include<stdio.h>
int main()
{
	int a, b, c, d, e;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	int sum = 0;
	sum = a % 3;
	a = a / 3;
	b = a + b;
	e = a + e;
	sum = b % 3 +sum;
	b = b / 3;
	a = b + a;
	c = b + c;
	sum = c % 3 + sum;
	c = c / 3;
	b = c + b;
	d = c + d;
	sum = d % 3 + sum;
	d = d / 3;
	c = d + c;
	e = d + e;
	sum = e % 3 +sum;
	e = e/ 3;
	d = e + d;
	a = e + a;
	printf("%d %d %d %d %d\n",a,b,c,d,e);
	printf("%d",sum);
	return 0;
}
